﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
using Portal.Web.Global;
using Portal.Web.Framework;
using Portal.Utilities;
using Portal.AssetTn.Model;
using System.IO;
using Portal.Core;

namespace Portal.Gui.Web.WebParts.AssetTn
{
    public class AssetStatus : WebPart
    {
        public override string WebPartId
        {
            get
            {
                return "AssetStatus";
            }
        }


        public override string Title
        {
            get
            {
                return "Trạng thái hiện vật";
            }
        }

        public override WebPartServiceCls WebPartService
        {
            get
            {
                return AssetUtility.WebPartService;
            }
        }


        public override string GetPluginJavascript(string SiteId)
        {
            return AjaxAssetStatusProcess.GetPlugInJavascript(SiteId);
        }

       
        public override string RenderWebPart(LoadParamCls loadParamCls)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxAssetStatusProcess));
            string SiteId = loadParamCls.SiteId;
            Environments.CheckSessionTimeOut(true);
            Permission.CheckPermission(
                      SiteId,
                      Environments.CurrentLoginUser.LoginName,
                      Portal.AssetTn.Security.Permission.GetPermissionId(),
                      Portal.AssetTn.Security.Permission.ePermisionType.Portal_AssetTn_Main.ToString(),
                      Portal.AssetTn.Security.Permission.eFunction.Portal_AssetTn_Admin.ToString(),
                      Portal.AssetTn.Security.Permission.GetPermissionId(),
                      null,
                      true);
            string RetHtml =
               GetPluginJavascript(SiteId)+
                "<input type=hidden id=\"txtPageIndex\" value=\"0\">\r\n" +
                "<div id=divActionForm>\r\n" +
                "</div>\r\n" +
                "<div id=\"divMainForm\" style=\"display:block;\">\r\n" +
                "   <div class=\"tabFunction\">Từ khóa: <input type=textbox class=textbox style=\"width:100px;\" id=txtKeyword>\r\n" +
                "       <input onclick=\"javascript:ClientJumpPage(0);\" type=button value=\"Đọc lại\">" +
                "       <input onclick=\"javascript:ClientShowFormAddAssetStatus();\" type=button value=\"Thêm mới\">" +
                "   </div>" +
                "   <div id=divProcessing></div>\r\n" +
                "   <div id=\"divAssetStatusContent\" class=\"tabcontent\">" +
                     AjaxAssetStatusProcess.ServerSideReading(SiteId, "", "0").HtmlContent +
                "   </div>" +
                "</div>\r\n";
            return RetHtml;
        }



        public override void RegAjaxPro(System.Web.UI.Page ActivePage)
        {
            AjaxPro.Utility.RegisterTypeForAjax(typeof(AjaxAssetStatusProcess), ActivePage);
        }
    }
}
